package edu.unf.cen6940.service;

import edu.unf.cen6940.domain.Category;
import edu.unf.cen6940.domain.Facultyresearch;
import edu.unf.cen6940.domain.Thesis;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/rms_test-security-context.xml",
		"file:./resources/rms_test-service-context.xml",
		"file:./resources/rms_test-dao-context.xml",
		"file:./resources/rms_test-web-context.xml" })
@Transactional
public class CategoryServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected CategoryService service;

	/**
	 * Instantiates a new CategoryServiceTest.
	 *
	 */
	public CategoryServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Load an existing Category entity
	 * 
	 */
	@Test
	public void loadCategorys() {
		Set<Category> response = null;
		response = service.loadCategorys();
		// TODO: JUnit - Add assertions to test outputs of operation: loadCategorys
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findCategoryByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findCategoryByPrimaryKey 
		Integer categoryId = 0;
		Category response = null;
		response = service.findCategoryByPrimaryKey(categoryId);
		// TODO: JUnit - Add assertions to test outputs of operation: findCategoryByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Facultyresearch entity
	 * 
	 */
	@Test
	public void deleteCategoryFacultyresearchs() {
		// TODO: JUnit - Populate test inputs for operation: deleteCategoryFacultyresearchs 
		Integer category_categoryId = 0;
		Integer related_facultyresearchs_facultyResearchId = 0;
		Category response = null;
		response = service.deleteCategoryFacultyresearchs(category_categoryId, related_facultyresearchs_facultyResearchId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCategoryFacultyresearchs
	}

	/**
	 * Operation Unit Test
	 * Save an existing Category entity
	 * 
	 */
	@Test
	public void saveCategory() {
		// TODO: JUnit - Populate test inputs for operation: saveCategory 
		Category category = new edu.unf.cen6940.domain.Category();
		service.saveCategory(category);
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Thesis entity
	 * 
	 */
	@Test
	public void deleteCategoryThesises() {
		// TODO: JUnit - Populate test inputs for operation: deleteCategoryThesises 
		Integer category_categoryId_1 = 0;
		Integer related_thesises_thesisId = 0;
		Category response = null;
		response = service.deleteCategoryThesises(category_categoryId_1, related_thesises_thesisId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCategoryThesises
	}

	/**
	 * Operation Unit Test
	 * Return all Category entity
	 * 
	 */
	@Test
	public void findAllCategorys() {
		// TODO: JUnit - Populate test inputs for operation: findAllCategorys 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Category> response = null;
		response = service.findAllCategorys(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllCategorys
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Category entity
	 * 
	 */
	@Test
	public void deleteCategory() {
		// TODO: JUnit - Populate test inputs for operation: deleteCategory 
		Category category_1 = new edu.unf.cen6940.domain.Category();
		service.deleteCategory(category_1);
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Category entity
	 * 
	 */
	@Test
	public void countCategorys() {
		Integer response = null;
		response = service.countCategorys();
		// TODO: JUnit - Add assertions to test outputs of operation: countCategorys
	}

	/**
	 * Operation Unit Test
	 * Save an existing Facultyresearch entity
	 * 
	 */
	@Test
	public void saveCategoryFacultyresearchs() {
		// TODO: JUnit - Populate test inputs for operation: saveCategoryFacultyresearchs 
		Integer categoryId_1 = 0;
		Facultyresearch related_facultyresearchs = new edu.unf.cen6940.domain.Facultyresearch();
		Category response = null;
		response = service.saveCategoryFacultyresearchs(categoryId_1, related_facultyresearchs);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCategoryFacultyresearchs
	}

	/**
	 * Operation Unit Test
	 * Save an existing Thesis entity
	 * 
	 */
	@Test
	public void saveCategoryThesises() {
		// TODO: JUnit - Populate test inputs for operation: saveCategoryThesises 
		Integer categoryId_2 = 0;
		Thesis related_thesises = new edu.unf.cen6940.domain.Thesis();
		Category response = null;
		response = service.saveCategoryThesises(categoryId_2, related_thesises);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCategoryThesises
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
